package com.pm.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pm.common.annotation.Log;
import com.pm.common.core.controller.BaseController;
import com.pm.common.core.domain.AjaxResult;
import com.pm.common.enums.BusinessType;
import com.pm.business.domain.BidProjectPoint;
import com.pm.business.service.IBidProjectPointService;
import com.pm.common.utils.poi.ExcelUtil;
import com.pm.common.core.page.TableDataInfo;

/**
 * 工作流Controller
 * 
 * @author zxl
 * @date 2022-05-17
 */
@RestController
@RequestMapping("/business/point")
public class BidProjectPointController extends BaseController
{
    @Autowired
    private IBidProjectPointService bidProjectPointService;

    /**
     * 查询工作流列表
     */
    @PreAuthorize("@ss.hasPermi('business:point:list')")
    @GetMapping("/list")
    public TableDataInfo list(BidProjectPoint bidProjectPoint)
    {
        startPage();
        List<BidProjectPoint> list = bidProjectPointService.selectBidProjectPointList(bidProjectPoint);
        return getDataTable(list);
    }

    /**
     * 导出工作流列表
     */
    @PreAuthorize("@ss.hasPermi('business:point:export')")
    @Log(title = "工作流", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BidProjectPoint bidProjectPoint)
    {
        List<BidProjectPoint> list = bidProjectPointService.selectBidProjectPointList(bidProjectPoint);
        ExcelUtil<BidProjectPoint> util = new ExcelUtil<BidProjectPoint>(BidProjectPoint.class);
        util.exportExcel(response, list, "工作流数据");
    }

    /**
     * 获取工作流详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:point:query')")
    @GetMapping(value = "/{bppId}")
    public AjaxResult getInfo(@PathVariable("bppId") Long bppId)
    {
        return AjaxResult.success(bidProjectPointService.selectBidProjectPointByBppId(bppId));
    }

    /**
     * 新增工作流
     */
    @PreAuthorize("@ss.hasPermi('business:point:add')")
    @Log(title = "工作流", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BidProjectPoint bidProjectPoint)
    {
        return toAjax(bidProjectPointService.insertBidProjectPoint(bidProjectPoint));
    }

    /**
     * 修改工作流
     */
    @PreAuthorize("@ss.hasPermi('business:point:edit')")
    @Log(title = "工作流", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BidProjectPoint bidProjectPoint)
    {
        return toAjax(bidProjectPointService.updateBidProjectPoint(bidProjectPoint));
    }

    /**
     * 删除工作流
     */
    @PreAuthorize("@ss.hasPermi('business:point:remove')")
    @Log(title = "工作流", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bppIds}")
    public AjaxResult remove(@PathVariable Long[] bppIds)
    {
        return toAjax(bidProjectPointService.deleteBidProjectPointByBppIds(bppIds));
    }
}
